<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *举报
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','title'=>'待核实举报信息'),
	array('op'=>'heshi','title'=>'已核实举报信息'),
	array('op'=>'hulue','title'=>'已忽略举报信息'),
);
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['status']=0;
	if(!empty($_RQ['nickname'])){
		$mid=pdo_getcolumn('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'nickname like %'=>$_RQ['nickname'].'%'),'mid');
		$params['mid']=$mid;
		$return['params']['mid']=$mid;
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','mid','pid','reason','type','isshouli','status','createtime','images');
	$list=pdo_getslice('jy_zhongchou_jubao',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$member=pdo_get('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$item['mid']));
			$project=pdo_get('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['pid']));
			$item['nickname']=$member['nickname'];
			$item['avatar']=$member['avatar'];
			$item['title']=$project['title'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'title','title'=>'被举报项目','type'=>'string'),
			array('name'=>'nickname','title'=>'昵称','type'=>'string'),
			array('name'=>'avatar','title'=>'头像','type'=>'image'),
			array('name'=>'type','title'=>'举报类型','type'=>'radio','options'=>'type'),
			array('name'=>'reason','title'=>'理由','type'=>'string'),
			//array('name'=>'images','title'=>'补充截图','type'=>'images'),
			array('name'=>'createtime','title'=>'举报时间','type'=>'time'),
		),
		'action' => 
		    array (
			       array('type'=>'post','op'=>'ok','title'=>'核实','message'=>'确定核实这条举报信息吗！'),
			       array('type'=>'post','op'=>'no','title'=>'忽略','message'=>'确定忽略这条举报信息吗！'),
				   ),),
		'search'=>array(
			array('name'=>'nickname','width'=>15,'title'=>'昵称','type'=>'string'),
		)
	);
	$return['type']=array('1'=>'筹款金额超过疾病所需','2'=>'多次筹款(包括其他平台)','3'=>'病情描述不符','4'=>'家庭经济情况良好','5'=>'患者已去世','6'=>'患者有购买保险、有医疗赔付','7'=>'事故纠纷','8'=>'虚假筹款','9'=>'其他');
	$return['htmls']=$htmls;
	exi($return);
}

if($_RQ['op']=='heshi'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['status']=1;
	if(!empty($_RQ['nickname'])){
		$mid=pdo_getcolumn('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'nickname like %'=>$_RQ['nickname'].'%'),'mid');
		$params['mid']=$mid;
		$return['params']['mid']=$mid;
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','mid','pid','reason','type','isshouli','status','createtime','images');
	$list=pdo_getslice('jy_zhongchou_jubao',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$member=pdo_get('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$item['mid']));
			$project=pdo_get('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['pid']));
			$item['nickname']=$member['nickname'];
			$item['avatar']=$member['avatar'];
			$item['title']=$project['title'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'title','title'=>'被举报项目','type'=>'string'),
			array('name'=>'nickname','title'=>'昵称','type'=>'string'),
			array('name'=>'avatar','title'=>'头像','type'=>'image'),
			array('name'=>'type','title'=>'举报类型','type'=>'radio','options'=>'type'),
			array('name'=>'reason','title'=>'理由','type'=>'string'),
			//array('name'=>'images','title'=>'补充截图','type'=>'images'),
			array('name'=>'createtime','title'=>'举报时间','type'=>'time'),
			array('name'=>'overtime','title'=>'处理时间','type'=>'string'),
		)),
		'search'=>array(
			array('name'=>'nickname','width'=>15,'title'=>'昵称','type'=>'string'),
		)
	);
	$return['type']=array('1'=>'筹款金额超过疾病所需','2'=>'多次筹款(包括其他平台)','3'=>'病情描述不符','4'=>'家庭经济情况良好','5'=>'患者已去世','6'=>'患者有购买保险、有医疗赔付','7'=>'事故纠纷','8'=>'虚假筹款','9'=>'其他');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='hulue'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['status']=2;
	if(!empty($_RQ['nickname'])){
		$mid=pdo_getcolumn('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'nickname like %'=>$_RQ['nickname'].'%'),'mid');
		$params['mid']=$mid;
		$return['params']['mid']=$mid;
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','mid','pid','reason','type','isshouli','status','createtime','images');
	$list=pdo_getslice('jy_zhongchou_jubao',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$member=pdo_get('jy_zhongchou_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$item['mid']));
			$project=pdo_get('jy_zhongchou_project',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['pid']));
			$item['nickname']=$member['nickname'];
			$item['avatar']=$member['avatar'];
			$item['title']=$project['title'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'title','title'=>'被举报项目','type'=>'string'),
			array('name'=>'nickname','title'=>'昵称','type'=>'string'),
			array('name'=>'avatar','title'=>'头像','type'=>'image'),
			array('name'=>'type','title'=>'举报类型','type'=>'radio','options'=>'type'),
			array('name'=>'reason','title'=>'理由','type'=>'string'),
			//array('name'=>'images','title'=>'补充截图','type'=>'images'),
			array('name'=>'createtime','title'=>'举报时间','type'=>'time'),
			array('name'=>'overtime','title'=>'处理时间','type'=>'string'),
		)),
		'search'=>array(
			array('name'=>'nickname','width'=>15,'title'=>'昵称','type'=>'string'),
		)
	);
	$return['type']=array('1'=>'筹款金额超过疾病所需','2'=>'多次筹款(包括其他平台)','3'=>'病情描述不符','4'=>'家庭经济情况良好','5'=>'患者已去世','6'=>'患者有购买保险、有医疗赔付','7'=>'事故纠纷','8'=>'虚假筹款','9'=>'其他');
	$return['htmls']=$htmls;
	exi($return);
}


if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_zhongchou_jubao',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
if($_RQ['op']=='ok'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择要核实的信息！','error');
	}
	pdo_update('jy_zhongchou_jubao',array('status'=>1,'overtime'=>TIMESTAMP),array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	exi('已核实该举报！');
}
if($_RQ['op']=='no'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择要忽略的信息！','error');
	}
	pdo_update('jy_zhongchou_jubao',array('status'=>2,'overtime'=>TIMESTAMP),array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	exi('已忽略该举报！');
}